package com.example.pictureview.widget;

import android.app.Dialog;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.view.Display;
import android.view.ViewGroup;
import android.view.WindowManager;

import com.example.pictureview.R;
import com.example.pictureview.adapter.ImageAdapter;

import java.util.List;

/**
 * Created by Administrator on 2017/9/21 0021.
 */

public class PictureDialog extends Dialog {
    private ImageLoader mImageLoader;

    public PictureDialog(Context context, ImageLoader imageLoader) {
        this(context, R.style.PictureDialog, imageLoader);
    }

    public PictureDialog(Context context, int themeResId, ImageLoader imageLoader) {
        super(context, themeResId);
        mImageLoader = imageLoader;
        init();
    }


    private ViewPager mViewPager;

    private void init() {
        mViewPager = new MyViewPager(getContext());
        Display display = getWindow().getWindowManager().getDefaultDisplay();
        setContentView(mViewPager, new WindowManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT));
    }

    public void setImageUrls(int curr, List<String> urls) {
        ImageAdapter adapter = new ImageAdapter(getContext(), mImageLoader, urls);
        mViewPager.setAdapter(adapter);
        mViewPager.setCurrentItem(curr);
    }


}
